//
//  ConnectCustomerViewController.m
//  Learn
//
//  Created by zyl_macbookpro on 2024/4/1.
//  Copyright © 2024 迟建国. All rights reserved.
//

#import "ConnectCustomerViewController.h"

@interface ConnectCustomerViewController ()<UITableViewDelegate,UITableViewDataSource>

@property(nonatomic ,strong)UITableView *tableView;

@property(nonatomic ,strong)NSArray *titleArray;

@property(nonatomic ,strong)UIView *tableFootorView;

@end

@implementation ConnectCustomerViewController
- (void)viewWillAppear:(BOOL)animated
{
    [super viewWillAppear:animated];
    [self renderNavBarWithBackgroundImage:[UIImage imageWithColor:lWhiteColor] backgroundColor:lClearColor shadowColor:nil textAttributeDic:@{NSForegroundColorAttributeName:rgba(51, 51, 51, 1),NSFontAttributeName:MFontWithSize(18)} enableScrollEdgeAppearance:NO];
}
- (void)viewDidLoad {
    [super viewDidLoad];
    
    self.title = @"客服电话";
    // Do any additional setup after loading the view.
    [self setBackButtonIsHidden:NO];
    [self.view addSubview:self.tableView];
    self.view.backgroundColor = rgba(245, 245, 245, 1);
}
#pragma mark -UITableViewDelegate,UITableViewDelegate
-(UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
    UITableViewCell *cell = nil;
    
    if (!cell)
    {
        cell = [[UITableViewCell alloc] initWithStyle:UITableViewCellStyleValue1 reuseIdentifier:@""];
        //cell.selectionStyle =UITableViewCellSelectionStyleNone;
    }
    [cell removeAllSubviews];
    UILabel *detailTextLabel = [[UILabel alloc] initWithFrame:CGRectMake(lScreenWidth/2.0, 0, lScreenWidth/2.0 - 10, 62)];
    detailTextLabel.textAlignment = NSTextAlignmentRight;
    UILabel *textLabel = [[UILabel alloc] initWithFrame:CGRectMake(10, 0, lScreenWidth/2.0 - 10, 62)];
    detailTextLabel.textColor = rgba(51, 51, 51, 1);
    if ([self.titleArray[indexPath.row] isEqualToString:@"客服电话"]) {
        
        detailTextLabel.text = lApp.mobileCustomer;
        
    }
    if ([self.titleArray[indexPath.row] isEqualToString:@"客服微信"]) {
        detailTextLabel.text = lApp.wechat_no;
    }
   
    textLabel.text = self.titleArray[indexPath.row];
    textLabel.font = MFontWithSize(16);
    textLabel.textColor = rgba(51, 51, 51, 1);
    detailTextLabel.font = MFontWithSize(16);
    [cell addSubview:textLabel];
    [cell addSubview:detailTextLabel];
    return cell;
}

-(NSInteger)numberOfSectionsInTableView:(UITableView *)tableView
{
    return 1;
}

-(NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section{
    
    return self.titleArray.count;
    
}

-(CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath
{
    
    return 62;
    
}

-(void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath
{
    if ([self.titleArray[indexPath.row] isEqualToString:@"客服电话"]) {
        
        [MethodTool callWithMobileNumber:lApp.mobileCustomer];
        
    }
    
}
#pragma mark -getters and setters
-(UITableView *)tableView{
    if (!_tableView){
        _tableView =[[UITableView alloc] initWithFrame:CGRectMake(0, lTopBarHeight, lScreenWidth, lScreenHeight - lTopBarHeight) style:UITableViewStylePlain];
        [_tableView setDelegate:self];
        [_tableView setDataSource:self];
        _tableView.bounces = NO;
        [_tableView setBackgroundColor:lWhiteColor];
        [_tableView setSeparatorColor:rgba(229, 229, 229, 1)];
        [_tableView setSeparatorInset:UIEdgeInsetsMake(0, 10, 0, 0)];
        [_tableView setTableFooterView:self.tableFootorView];
    }
    
    return _tableView;
}
-(UIView *)tableFootorView
{
    if (!_tableFootorView)
    {
        _tableFootorView =[[UIView alloc] initWithFrame:CGRectMake(0, 0, lScreenWidth, 212)];
        _tableFootorView.backgroundColor = lWhiteColor;
        UILabel *titleLabel = [[UILabel alloc] init];
        titleLabel.frame = CGRectMake(10,20,lScreenWidth - 20,22);
        titleLabel.font = MFontWithSize(16);
        titleLabel.textColor = rgba(51, 51, 51, 1);
        titleLabel.textAlignment = NSTextAlignmentLeft;
        titleLabel.text = @"微信二维码";
        UIImageView *lampView = [[UIImageView alloc] initWithFrame:CGRectMake((lScreenWidth - 140)/2.0, 72, 140, 140)];
        [lampView sd_setImageWithURL:[NSURL URLWithString:lApp.wechat_img]];
        [_tableFootorView addSubview:lampView];
        [_tableFootorView addSubview:titleLabel];
    }
    
    return _tableFootorView;
    
}
- (NSArray *)titleArray
{
    if (!_titleArray) {
        _titleArray = @[@"客服电话",@"客服微信"];
    }
    return _titleArray;
}

/*
#pragma mark - Navigation

// In a storyboard-based application, you will often want to do a little preparation before navigation
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
    // Get the new view controller using [segue destinationViewController].
    // Pass the selected object to the new view controller.
}
*/

@end
